package com.example.ymm.modules1.service.impl.sys;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.ymm.base.BaseServiceImpl;
import com.example.ymm.model.TableList;
import com.example.ymm.model.YmPageDto;
import com.example.ymm.modules1.entity.my.sys.SysNoteMsg;
import com.example.ymm.modules1.mapper.my.sys.SysNoteMsgMapper;
import com.example.ymm.modules1.query.sys.SysNoteMsgQueryCriteria;
import com.example.ymm.modules1.service.sys.SysNoteMsgService;
import com.example.ymm.util.QueryHelpPlus;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
@Slf4j
public class SysNoteMsgServiceImpl extends BaseServiceImpl<SysNoteMsgMapper, SysNoteMsg> implements SysNoteMsgService {

    @Override
    public TableList<SysNoteMsg> list(SysNoteMsgQueryCriteria criteria, YmPageDto pageDto) {
        IPage<SysNoteMsg> page = new Page<SysNoteMsg>(pageDto.getPage(),pageDto.getPageSize());
        QueryWrapper predicate = QueryHelpPlus.getPredicate(SysNoteMsg.class, criteria);
        predicate.orderByDesc("create_time");
        baseMapper.selectPage(page, predicate);
        TableList<SysNoteMsg> tableList=new TableList(page);
        return tableList;
    }

    public List<SysNoteMsg> queryAll(SysNoteMsgQueryCriteria criteria) {
        QueryWrapper predicate = QueryHelpPlus.getPredicate(SysNoteMsg.class, criteria);
        predicate.orderByDesc("create_time");
        List<SysNoteMsg> result =baseMapper.selectList(predicate);
        return result;
    }
}
